package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.Customer;
import com.atguigu.jxc.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping
public class CustomerController {
    @Autowired
    private CustomerService customerService;

    /**
     * 客户列表分页（名称模糊查询）
     * @param page
     * @param rows
     * @param customerName
     * @return
     */
    @PostMapping("/customer/list")
    public Map<String,Object> customerList(Integer page, Integer rows, String customerName){
        return customerService.getCustomerList(page,rows,customerName);
    }

    /**
     * 客户添加或修改
     * @param customer
     * @return
     */
    @PostMapping("/customer/save")
    public ServiceVO customerSave(Customer customer){
        return customerService.customerSave(customer);
    }

    /**
     * 批量删除
     * @param ids
     * @return
     */
     @PostMapping("/customer/delete")
    public ServiceVO customerDelete(String ids){
        return customerService.customerDelete(ids);
     }
}
